DEFINITION FOR C MODULE AmigaLib ;

FROM SYSTEM	IMPORT ADDRESS, STRING, SHORTREAL, LONGSET ;
FROM Exec	IMPORT IORequestPtr, TaskPtr, MsgPortPtr, IOStdReqPtr, ListPtr,
		       MessagePtr ;
FROM Classes	IMPORT IClassPtr, ObjectPtr, Msg ;
FROM Utility	IMPORT HookPtr, Tag ;
FROM Workbench	IMPORT ToolTypeArrayPtr ;
FROM Graphics	IMPORT IsrvstrPtr ;
FROM Timer	IMPORT TimeValPtr ;
FROM InputEvent IMPORT InputEventPtr ;
FROM KeyMap	IMPORT KeyMapPtr ;

IMPORT Commodities ;

(* Exec support functions *)

PROCEDURE BeginIO    ( ioReq : IORequestPtr ) ;
PROCEDURE CreateExtIO( port  : MsgPortPtr ; ioSize : LONGINT ) : IORequestPtr ;
PROCEDURE CreatePort ( name  : STRING ; pri : LONGINT ) : MsgPortPtr ;
PROCEDURE CreateStdIO( port  : MsgPortPtr ) : IOStdReqPtr ;

PROCEDURE CreateTask( name   : STRING ;
		      pri    : LONGINT ;
		      initPC : ADDRESS ;
		      stackSize : LONGINT ) : TaskPtr ;

PROCEDURE DeleteExtIO( ioReq : IORequestPtr ) ;
PROCEDURE DeletePort( ioReq : MsgPortPtr ) ;
PROCEDURE DeleteStdIO( ioReq : IOStdReqPtr ) ;
PROCEDURE DeleteTask( task : TaskPtr ) ;
PROCEDURE NewList( list : ListPtr ) ;

PROCEDURE LibAllocPooled( poolHeader : ADDRESS ; memSize : LONGINT ) : ADDRESS ;
PROCEDURE LibCreatePool( memFlags   : LONGSET ;
			 puddleSize : LONGINT ;
			 threshSize : LONGINT ) : ADDRESS ;

PROCEDURE LibDeletePool( poolHeader : ADDRESS ) ;
PROCEDURE LibFreePooled( poolHeader, memory : ADDRESS ; memSize : LONGINT ) ;

(* Assorted functions in amiga.lib *)

PROCEDURE FastRand( seed : LONGINT ) : LONGINT ;
PROCEDURE RangeRand( maxValue : LONGINT ) : CARDINAL ;

(* Graphics support functions in amiga.lib *)

PROCEDURE AddTOF( i : IsrvstrPtr ; p : PROC (* cast it *) ; a : LONGINT );
PROCEDURE RemTOF( i : IsrvstrPtr ) ;
PROCEDURE waitbeam( b : LONGINT ) ;

(* math support functions in amiga.lib *)

PROCEDURE afp  ( string : STRING ) : SHORTREAL ;
PROCEDURE arnd ( place, exp : LONGINT ; string : STRING ) ;
PROCEDURE dbf  ( exp  : LONGINT ; mant : LONGINT ) : SHORTREAL ;
PROCEDURE fpa  ( fnum : SHORTREAL ; string : STRING ) : LONGINT ;
PROCEDURE fpbcd( fnum : SHORTREAL ; string : STRING ) ;

(* Timer support functions in amiga.lib (V36 and higher only) *)

PROCEDURE TimeDelay( unit : LONGINT ;
		     secs : LONGINT ;
                     microsecs : LONGINT ) : LONGINT ;

PROCEDURE DoTimer( tvp : TimeValPtr ; unit , command : LONGINT ) : LONGINT ;

(*  Commodities functions in amiga.lib (V36 and higher only) *)

PROCEDURE ArgArrayDone( ) ;

PROCEDURE ArgArrayInit( argc : LONGINT ;
			argv : ADDRESS ) : ToolTypeArrayPtr ;

PROCEDURE ArgInt( tt	     : ToolTypeArrayPtr ;
		  entry	     : STRING ;
		  defaultval : LONGINT ) : LONGINT ;

PROCEDURE ArgString( tt : ToolTypeArrayPtr ;
		     entry , defaulstring : STRING ) : STRING ;

PROCEDURE HotKey( description : STRING ;
		  port	      : MsgPortPtr ;
		  id	      : LONGINT ) : Commodities.CxObjPtr ;

PROCEDURE InvertString( str : STRING ; km : KeyMapPtr ) : InputEventPtr ;
PROCEDURE FreeIEvents( events : InputEventPtr ) ;

(*  ARexx support functions in amiga.lib *)

PROCEDURE CheckRexxMsg( rexxmsg : MessagePtr ) : BOOLEAN ;

PROCEDURE GetRexxVar(     rexxmsg : MessagePtr ;
		          name    : STRING ;
		      VAR result  : STRING ) : LONGINT ;

PROCEDURE SetRexxVar( rexxmsg : MessagePtr ;
		      name    : STRING ;
		      length  : LONGINT ) : LONGINT ;

(*  Intuition hook and boopsi support functions in amiga.lib.		  *)
(*  These functions do not require any particular ROM revision		  *)
(*  to operate correctly, though they deal with concepts first introduced *)
(*  in V36.  These functions would work with compatibly-implemented	  *)
(*  hooks or objects under V34.						  *)

PROCEDURE CallHookA( hookPtr : HookPtr ;
		     obj     : ObjectPtr ;
		     message : ADDRESS ) : LONGINT ;

PROCEDURE CallHook ( hookPtr : HookPtr ; obj : ObjectPtr ; .. ) : LONGINT ;
PROCEDURE DoMethodA( obj : ObjectPtr ; message  : Msg ) : LONGINT ;
PROCEDURE DoMethod ( obj : ObjectPtr ; MethodID : LONGINT ; .. ) : LONGINT ;

PROCEDURE DoSuperMethodA( cl	  : IClassPtr ;
			  obj	  : ObjectPtr ;
			  message : Msg ) : LONGINT ;

PROCEDURE DoSuperMethod( cl 	  : IClassPtr ;
			 obj	  : ObjectPtr ;
			 MethodID : LONGINT ; .. ) : LONGINT ;

PROCEDURE CoerceMethodA( cl 	 : IClassPtr ;
			 obj	 : ObjectPtr ;
			 message : Msg ) : LONGINT ;

PROCEDURE CoerceMethod( cl	 : IClassPtr ;
			obj	 : ObjectPtr ;
			MethodID : LONGINT ; .. ) : LONGINT ;

PROCEDURE SetSuperAttrs( cl   : IClassPtr ;
			 obj  : ObjectPtr ;
			 Tag1 : Tag ; .. ) : LONGINT ;

(* Network-support functions in amiga.lib.			   *)
(* ACrypt() first appeared in later V39 versions of amiga.lib, but *)
(* operates correctly under V37 and up.				   *)

PROCEDURE ACrypt( buffer : ADDRESS ; password, username : STRING ) : STRING ;

END AmigaLib.
